# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models
from datetime import datetime
#import django.db.models.options as options
# Create your models here.

class UserInfo(models.Model):
    ''''用户信息'''
    UID = models.AutoField(primary_key=True)
    WechatOpenid =models.CharField(verbose_name=u'公众平台id', default=None, help_text='公众平台id',max_length=45)
    NickName = models.CharField(verbose_name=u'昵称', default=None, help_text='昵称',max_length=45)
    Sex = models.IntegerField(null=True,verbose_name=u'性别', help_text='性别')
    Country =  models.CharField(verbose_name=u'国家', default=None, help_text='国家',max_length=45)
    Province =  models.CharField(verbose_name=u'省份', default=None, help_text='省份',max_length=45)
    City = models.CharField(verbose_name=u'城市', default=None, help_text='城市',max_length=45)
    Language = models.CharField(null=True,verbose_name=u'语言',help_text='语言',max_length=45)
    HeadImgUrl = models.CharField(null=True,verbose_name=u'头像URL', help_text='头像URL',max_length=200)
    SubscribeTime = models.IntegerField(null=True,verbose_name=u'首次登录时间', help_text='首次登录时间')
    
    AvatarId = models.IntegerField(null=True,verbose_name=u'选择人物类型', help_text='选择人物类型')
    LastLoginTime = models.IntegerField(null=True,verbose_name=u'最后登录时间', help_text='最后登录时间')
    IsOnline =models.IntegerField(default=0,verbose_name=u'是否在线', help_text='是否在线')
    LoginMachine=models.IntegerField(null=True,verbose_name=u'登录机器MID', help_text='登录机器MID')
    all_recharge=models.FloatField(default=0,verbose_name=u'用户总充值金额', help_text='用户总充值金额')
    all_consume=models.FloatField(default=0,verbose_name=u'用户总消费金额', help_text='用户总消费金额')
    IsActive =models.IntegerField(default=0,verbose_name=u'是否活跃', help_text='是否活跃')
    kCoin =models.IntegerField(default=0,verbose_name=u'剩余K币', help_text='剩余K币')
    ActiveTime=models.IntegerField(default=0,verbose_name=u'用户活跃分钟',help_text='用户活跃分钟')
    LoginTimes=models.IntegerField(default=0,verbose_name=u'登录次数',help_text='登录次数')
    WinTimes=models.IntegerField(default=0,verbose_name=u'比赛赢的次数',help_text='比赛赢的次数')
    DefeatTimes=models.IntegerField(default=0,verbose_name=u'比赛输的次数',help_text='比赛输的次数')
    class Meta:
        db_table =  'UserInfo'
class MachineInfo(models.Model):
    MachineId = models.AutoField(primary_key=True)
    QRCodeUrl =models.CharField(verbose_name=u'机器二维码', default=None, help_text='机器二维码',max_length=200)
    HARD_SN = models.CharField(verbose_name=u'硬盘编号', default=None, help_text='硬盘编号',max_length=255)
    DEVICE_ID = models.CharField(verbose_name=u'效果器编号', default=None, help_text='效果器编号',max_length=255)
    VOD_VERSION = models.CharField(null=True,verbose_name=u'系统版本好', default=None, help_text='系统版本号',max_length=255)
    RES_VERSION = models.CharField(null=True,verbose_name=u'资源版本号', default=None, help_text='资源版本号',max_length=255)
    AREA = models.CharField(verbose_name=u'地区', default=None, help_text='地区',max_length=255)
    HEARTBEAT_TIME = models.IntegerField(default=0,verbose_name=u'最后上线时间', help_text='最后上线时间')
    VOD_UPDATE_VERSION = models.CharField(null=True,verbose_name=u'资源升级版本号', default=None, help_text='资源升级版本号',max_length=255)
    VOD_UPDATE_STATUS = models.CharField(verbose_name=u'系统升级状态', default=None, help_text='系统升级状态',max_length=255)
    RES_UPDATE_VERSION = models.CharField(null=True,verbose_name=u'资源升级版本号', default=None, help_text='资源升级版本号',max_length=255)
    RES_UPDATE_STATUS = models.CharField(verbose_name=u'资源升级状态', default=None, help_text='资源升级状态',max_length=255)
    LOGIN_DAY = models.CharField(verbose_name=u'登录天数', default=None, help_text='登录天数',max_length=255)
    SYSTEM_VERSION = models.CharField(null=True,verbose_name=u'系统脚本版本', default=None, help_text='系统脚本版本',max_length=255)
    APP_BOOT_VERSION = models.CharField(null=True,verbose_name=u'昵称', default=None, help_text='小脚本版本',max_length=255)
    SHARK_BASE_VERSION = models.CharField(null=True,verbose_name=u'昵称', default=None, help_text='shark基础版本',max_length=255)
    SHARK_VERSION = models.CharField(null=True,verbose_name=u'昵称', default=None, help_text='shark版本',max_length=255)
    HEARTBEAT_INTERVAL= models.CharField(verbose_name=u'昵称', default=None, help_text='心跳时间',max_length=255)
    STATUS = models.IntegerField(default=0,verbose_name=u'机器激活状态', help_text='机器激活状态')
    MACHINE_NAME = models.CharField(verbose_name=u'机器名称', default=None, help_text='机器名称',max_length=255)
    ACTIVE_TIME = models.DateTimeField(verbose_name=u'激活时间', default=None, help_text='激活时间',max_length=255)
    ALL_INCOME = models.FloatField(default=0,verbose_name=u'机器总收入', help_text='机器总收入')
    ON_LINE = models.IntegerField(verbose_name=u'机器在线状态', help_text='机器在线状态',default=0)

    class Meta:
        db_table =  'MachineInfo'

class user_recharge(models.Model):
    recharge_id = models.AutoField(primary_key=True)
    recharge_type= models.IntegerField(verbose_name=u'充值类型', help_text='充值类型')
    mount = models.FloatField(default=0,verbose_name=u'用户总充值金额', help_text='用户总充值金额')
    recharge_orderid = models.CharField(null=False,verbose_name=u'', default=None, help_text='充值订单号',max_length=255)
    mid = models.IntegerField(verbose_name=u'订单产生机器MID', help_text='订单产生机器MID')
    recharge_status = models.IntegerField(verbose_name=u'充值状态', help_text='充值状态')
    recharge_time = models.DateTimeField( verbose_name=u'充值日期', help_text='充值日期')
    recharge_description = models.CharField(verbose_name=u'', default=None, help_text='充值描述',max_length=255)
    uid = models.IntegerField(verbose_name=u'订单产生机器UID', help_text='订单产生机器UID')
    recharge_day = models.DateField( verbose_name=u'充值日', help_text='充值日')
    class Meta:
        db_table =  'user_recharge'
class user_consume(models.Model):
    oid =  models.AutoField(primary_key=True)
    order_type= models.IntegerField(default=1)
    mount = models.FloatField(default=0)
    order_sn = models.CharField(null=False,verbose_name=u'订单号', default=None, help_text='订单号',max_length=255)
    mid = models.IntegerField()
    status = models.IntegerField(default = 1)
    pay_time = models.DateTimeField(verbose_name=u'消费日期', help_text='消费日期')
    description = models.CharField(verbose_name=u'', default=None, help_text='消费描述',max_length=255)
    uid = models.IntegerField(verbose_name=u'订单产生机器UID', help_text='订单产生机器UID')

    class Meta:
        db_table =  'user_consume'

class store_info(models.Model):
    storeid =  models.AutoField(primary_key=True)
    merchantid = models.IntegerField()
    storename = models.CharField(verbose_name=u'', default=None, help_text='门店名称',max_length=255)
    address = models.CharField(verbose_name=u'', default=None, help_text='地址',max_length=255)
    machine_num = models.IntegerField(default=0)
    all_income = models.FloatField(default=0)
    is_defaultgroup = models.IntegerField(default = 0)
    store_status = models.IntegerField(default = 1)
    start_time = models.DateTimeField()
    end_time = models.DateTimeField()

    
    class Meta:
        db_table =  'store_info'
class store_report(models.Model):
    storeid =models.IntegerField()
    all_income = models.FloatField(default=0)
    mobile_income = models.FloatField(default = 0)
    datetime = models.DateField()

    class Meta:
        db_table =  'store_report'
class machine_report(models.Model):
    mid =models.IntegerField()
    all_income = models.FloatField(default=0)
    mobile_income = models.FloatField(default = 0)
    datetime = models.DateField()

    class Meta:
        db_table =  'machine_report'
class machine_relation(models.Model):
    mid = models.IntegerField()
    storeid = models.IntegerField()
    merchantid = models.IntegerField()
    updatetime = models.DateTimeField()
    
    class Meta:
        db_table =  'machine_relation'
class merchant_info(models.Model):
    merchantid = models.AutoField(primary_key=True)
    merchantname = models.CharField(verbose_name=u'商户名', default=None, help_text='商户名',max_length=255)
    username = models.CharField(null=True,verbose_name=u'商户用户名', default=None, help_text='商户用户名',max_length=255)
    password = models.CharField(null=False,verbose_name=u'密码', default=None, help_text='密码',max_length=255)
    realname = models.CharField(null=True,verbose_name=u'真实姓名', default=None, help_text='真实姓名',max_length=255)
    mobile = models.CharField(null=False,verbose_name=u'手机号', default=None, help_text='手机号',max_length=13)
    IDcard = models.CharField(null=False,verbose_name=u'身份证', default=None, help_text='身份证',max_length=20)
    updatetime = models.DateTimeField()
    all_income = models.FloatField(default = 0)
    #imgurl = models.CharField(verbose_name=u'头像', default=None, help_text='头像',max_length=255)
    imgurl= models.FileField(verbose_name=u"头像", upload_to="merchantinfo/imgurl/", max_length=255,help_text='头像url', blank=True)

    sex = models.IntegerField(default =1 )
    area = models.CharField(null=True,verbose_name=u'地区', default=None, help_text='地区',max_length=255)
    bankcard  = models.CharField(null=True,verbose_name=u'银行卡', default=None, help_text='银行卡',max_length=255)
    recvaddress = models.CharField(null=True,verbose_name=u'收货地址', default=None, help_text='收获地址',max_length=255)
    is_super = models.IntegerField(verbose_name=u'是否为管理员',default = 0)
    withdraw = models.FloatField(verbose_name=u'已提现的金额',default = 0)


    class Meta:
        db_table =  'merchant_info'
class product_info(models.Model):
    productid = models.AutoField(primary_key=True)
    name = models.CharField(verbose_name=u'', default=None, help_text='充值描述',max_length=255)
    price = models.FloatField(default=0.00)
    picurl = models.CharField(verbose_name=u'', default=None, help_text='充值描述',max_length=255)
    description = models.CharField(verbose_name=u'', default=None, help_text='充值描述',max_length=255)
    detail_picurl = models.CharField(verbose_name=u'', default=None, help_text='充值描述',max_length=255)

    class Meta:
        db_table =  'product_info'
class product_order(models.Model):
    orderid = models.AutoField(primary_key=True)
    merchantid = models.IntegerField()
    status =  models.CharField(verbose_name=u'订单状态 0加入购物车 1已支付 2已完成', default='0', help_text='订单状态',max_length=255)
    productid =  models.IntegerField()
    count  =  models.IntegerField()
    ordertime =  models.DateTimeField()
    
    class Meta:
        db_table =  'product_order'

class trade_package(models.Model):
    tradeid = models.AutoField(primary_key=True)
    tradename =  models.CharField(verbose_name=u'', default=None, help_text='充值描述',max_length=255) 
    price =  models.FloatField()
    status =  models.IntegerField(default=1)

    class Meta:
        db_table =  'trade_package'



#微生成
class wsc_class(models.Model):
    id = models.AutoField(primary_key=True)
    name =  models.CharField(verbose_name=u'', null=False, help_text='模板背景url',max_length=255) 

    class Meta:
        db_table =  'wsc_class'
class wsc_class_relation(models.Model):
    id = models.AutoField(primary_key=True)
    classid =  models.IntegerField(verbose_name=u'', null=False, help_text='类别id') 
    templateid =  models.IntegerField(verbose_name=u'', null=False, help_text='模板id') 

    class Meta:
        db_table =  'wsc_class_relation'
class wsc_template(models.Model):
    id = models.AutoField(primary_key=True)
    name =  models.CharField(verbose_name=u'',null=True,  help_text='模板名字',max_length=255) 
    #url=  models.CharField(verbose_name=u'', null=False, help_text='模板背景url',max_length=255) 
    url= models.FileField(verbose_name=u"模板背景图片", upload_to="templatepic/%y%m/", max_length=255,help_text='模板背景图片', blank=True)

    class Meta:
        db_table =  'wsc_template'
class wsc_template_relation(models.Model):
    id = models.AutoField(primary_key=True)
    templateid =  models.IntegerField(verbose_name=u'', null=False, help_text='模板名字') 
    key =  models.CharField(verbose_name=u'', null=False, help_text='关键词',max_length=255) 
    limit =  models.IntegerField(verbose_name=u'', null=False, help_text='内容字数限制') 
    placeholder =  models.CharField(verbose_name=u'', null=False, help_text='关键词提示语',max_length=255) 
    xPosition = models.IntegerField(verbose_name=u'',help_text="横坐标",default=0)
    
    yPosition = models.IntegerField(verbose_name=u'',help_text="纵坐标",default=0)

    class Meta:
        db_table =  'wsc_template_relation'



class Vod_errorlog(models.Model):
    id = models.AutoField(primary_key=True)
    mid =  models.IntegerField(verbose_name=u'', null=False, help_text='机器ID') 
    error_code =  models.CharField(verbose_name=u'', null=False, help_text='错误码',max_length=255) 
    error_info =  models.CharField(verbose_name=u'', null=False, help_text='错误描述',max_length=255) 
    error_time =  models.CharField(verbose_name=u'', null=False, help_text='上传时间',max_length=255) 
    class Meta:
        db_table = 'Vod_errorlog'
